/*
 * =====================================================================================
 *
 *       Filename:  buffer.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  01/23/2018 06:58:47 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  jianxi sun (jianxi), ycsunjane@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#ifndef __BUFFER_H__
#define __BUFFER_H__

#define BUF_SIZE 2048

typedef struct buffer {
	size_t idx;
	size_t len;
	size_t capacity;
	char   *array;
} buffer_t;

int balloc(buffer_t *ptr, size_t capacity);
void bfree(buffer_t *ptr);
buffer_t *bconcat(buffer_t *buf, char *data, int len);
void breset(buffer_t *ptr);
void bfree(buffer_t *ptr);
int bufempty(buffer_t *ptr);
void bshrink(buffer_t *ptr, int len);

#endif /* __BUFFER_H__ */
